package com.livesource.server.webservice;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.repackaged.org.json.JSONObject;
import com.livesource.server.database.project.GetProject;

@SuppressWarnings("serial")
public class GetProjectServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException {

		String returnValue = "Error";

		String projectID = request.getParameter("projectID");

		if (projectID != null) {

			JSONObject project = GetProject.jsonEntity(projectID);

			returnValue = Utilities.getCallback(
					request.getParameter("callback"), project.toString());
		}

		response.setContentType("text/javascript");

		String answer = Utilities.getCallback(request.getParameter("callback"),
				returnValue);

		response.getWriter().println(answer);
	}
}
